﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace ZombieGame
{
    public class Weapon
    {
        public static Weapon DesertEagle
        {
            get
            {
                Weapon w = new global::ZombieGame.Weapon();
                w.Damage = 1.9f;
                w.RateOfFire = 16f;
                w.ClipSize = 16;
                w.Ammo = 112;
                w.MaxAmmo = 112;
                w.Clip = 16;
                w.Penetration = 0.50f;
                w.ReloadCooldown = 2.5f;
                w.Name = "Desert Eagle";
                w.Type = WeaponType.SemiAutomatic;
                return w;
            }
        }
        public static Weapon MP5
        {
            get
            {
                Weapon w = new global::ZombieGame.Weapon();
                w.Damage = 3.5f;
                w.RateOfFire = 15f;
                w.ClipSize = 30;
                w.Ammo = 180;
                w.MaxAmmo = 180;
                w.Clip = 30;
                w.Penetration = 0.40f;
                w.ReloadCooldown = 2.53f;
                w.Name = "MP5";
                w.Type = WeaponType.Automatic;
                return w;
            }
        }
        public static Weapon M16A1
        {
            get
            {
                Weapon w = new global::ZombieGame.Weapon();
                w.Damage = 4f;
                w.RateOfFire = 13f;
                w.ClipSize = 30;
                w.Ammo = 120;
                w.MaxAmmo = 120;
                w.Clip = 30;
                w.Penetration = 0.20f;
                w.ReloadCooldown = 2.03f;
                w.Name = "M16A1";
                w.Type = WeaponType.Automatic;
                return w;
            }
        }
        public static Weapon Galil              
        {
            get
            {
                Weapon w = new global::ZombieGame.Weapon();
                w.Damage = 5f;
                w.RateOfFire = 12.5f;
                w.ClipSize = 35;
                w.Ammo = 315;
                w.MaxAmmo = 315;
                w.Clip = 35;
                w.Penetration = 0.25f;
                w.ReloadCooldown = 2.8f;
                w.Name = "Galil";
                w.Type = WeaponType.Automatic;
                return w;
            }
        }
        public static Weapon RPK    
        {
            get
            {
                Weapon w = new global::ZombieGame.Weapon();
                w.Damage = 5f;
                w.RateOfFire = 12f;
                w.ClipSize = 100;
                w.Ammo = 400;
                w.MaxAmmo = 400;
                w.Clip = 100;
                w.Penetration = 0.20f;
                w.ReloadCooldown = 4f;
                w.Name = "RPK";
                w.Type = WeaponType.Automatic;
                return w;
            }
        }
        public static Weapon Ranger //BAR FIX THE SHOTGUN SHIT, SHELLS, AND RANGE.
        {
            get
            {
                Weapon w = new global::ZombieGame.Weapon();
                w.Damage = 10f;
                w.RateOfFire = 1.5f;
                w.ClipSize = 2;
                w.Ammo = 40;
                w.MaxAmmo = 40;
                w.Clip = 2;
                w.Penetration = 0.25f;
                w.ReloadCooldown = 2f;
                w.Name = "Ranger";
                w.Type = WeaponType.Shotgun;
                return w;
            }
        }
        public static Weapon LaserGun //TODO a non bullet shot for this weapon (laser shot...)
        {
            get
            {
                Weapon w = new global::ZombieGame.Weapon();
                w.Damage = float.MaxValue;
                w.RateOfFire = 50f;
                w.ClipSize = 500;
                w.Ammo = 0;
                w.MaxAmmo = 500;
                w.Clip = 500;
                w.Penetration = 0f;
                w.ReloadCooldown = 0f;
                w.Name = "LaserGun";
                w.Type = WeaponType.Laser;
                return w;
            }
        }

        public float Damage;
        public float Penetration;
        public float RateOfFire;
        public int Ammo;
        public int Clip;
        public int ClipSize;
        public bool Reloading;
        public float ReloadCooldown;
        public string Name;
        public int MaxAmmo;
        public WeaponType Type;
        public void Reload()
        {
            Reloading = false;
            Ammo += Clip;
            int i = Math.Min(Ammo, ClipSize);
            Ammo -= i;
            Clip = i;
        }

        public Texture2D Texture;

        public static explicit operator Weapon(int i)
        {
            switch (i)
            {
                case 1:
                    return MP5;
                case 3:
                    return M16A1;
                case 4:
                    return Galil;
                case 5:
                    return RPK;
                case 2:
                    return Ranger;
                case 6:
                    return LaserGun;
                default:
                    return DesertEagle;
            }
        }
    }

    public enum WeaponType
    {
        SemiAutomatic = 0,
        Burst = 1,
        Automatic = 2,
        Shotgun = 3,
        Laser = 4
    }
}
